<template>
    <div class="login">
        <el-row>
            <el-col :span="14" :xs="4"></el-col>
            <el-col :span="10" :xs="20">
                <!-- 登录的表单 -->
                <el-form class="login_form" ref="loginForms" :model="userInfo" :rules="rules">
                    <h2>欢迎来到云枫村</h2>
                    <el-form-item prop="userName">
                        <el-input :prefix-icon="User" v-model="userInfo.userName"></el-input>
                    </el-form-item>
                    <el-form-item prop="password">
                        <el-input type="password" :prefix-icon="Lock" v-model="userInfo.password" show-password></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button :loading="loading" class="login_btn" type="primary" size="default"
                            @click="doLogin">登录</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
    </div>
</template>

<script lang="ts" setup>
import { User, Lock } from '@element-plus/icons-vue';
import useLogin from './useLogin';

const {
    userInfo, loading, doLogin, rules
} = useLogin();

</script>

<style lang="scss" scoped>
.login {
    height: 100vh;
    width: 100%;
    background: url('@/assets/images/background.jpg') no-repeat;
    background-size: cover;

    .login_form {
        position: relative;
        width: 80%;
        top: 30vh;
        background: url("@/assets/images/login_form.png") no-repeat;
        background-size: cover;
        padding: 40px;

        h1 {
            color: white;
            font-size: 40px;
        }

        h2 {
            font-size: 20px;
            color: white;
            margin: 20px 0px;
        }

        .login_btn {
            width: 100%;
        }
    }
}
</style>
